<%@ page contentType="text/html;charset=utf-8" %>
<%@ page language="java" import="weibo4j.http.*" %>
<%@ page language="java" import="weibo4j.*" import="weibo4j.model.*"%>
<%@ page import="com.ycy.ss.*" %>
<%@ page import="com.ycy.ss.status.*" %>
<%@ page import="java.util.*" %>

<!DOCTYPE html>
<!-- Template by freewebsitetemplates.com -->
<html>
<head>
<title>[幸运数查看工具]</title>
<link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
<!--[if IE 6]>
	<link rel="stylesheet" type="text/css" href="css/ie6.css" media="all" />
<![endif]-->
<!--[if IE 7]>
	<link rel="stylesheet" type="text/css" href="css/ie7.css" media="all" />
<![endif]-->
</head>
<body>
<%
	String code = request.getParameter("code");
	Oauth oauth = new Oauth();
	AccessToken accessToken = oauth.getAccessTokenByCode(code);
	
	StatusSina statusSina = new StatusSina();
	statusSina.ACCESS_TOKEN = accessToken;
	statusSina.readOk("0");
	
	Weibo weibo = new Weibo();
	weibo.setToken(accessToken.getAccessToken());
	
	Timeline tm = new Timeline();
	StatusWapper status = tm.getUserTimeline();
	List<Status> statusList = new ArrayList<Status>();
	for (Status s : status.getStatuses()) {
		statusList.add(s);
	}
	
	String num = statusList.size()==0?"0":statusList.get(0).getId();
		
		Map<String,String> map1 = new HashMap<String,String>();
		map1.put("1","行动、野心、领导、创新");
		map1.put("2","具有艺术气息、富想象力");
		map1.put("3","聪明、擅长社交、精力充沛");
		map1.put("4","务实、稳定、冷静");
		map1.put("5","冒险、有能力和创意");
		map1.put("6","代表忠实、可靠");
		map1.put("7","智能、神秘");
		map1.put("8","强悍、执着、物欲");
		map1.put("9","勇气、成就");
		
		Map<String,String> map2 = new HashMap<String,String>();
		map2.put("1","刚直不阿的正义者");
		map2.put("2","爱情忠实的守望者");
		map2.put("3","孑然一身的旅行者");
		map2.put("4","新新时代的叛逆者");
		map2.put("5","随遇而安的求生者");
		map2.put("6","逆向思维的睿智者");
		map2.put("7","志存高远的理想者");
		map2.put("8","锲而不舍的爱美者");
		map2.put("9","相得益彰的矛盾者");
		
		num = (Long.parseLong(num)%9+1)+"";
%>
	<div id="header">
		<div>
			<ul>
				<li class="selected"><a href="call.jsp">home</a></li>	
				<li><a href="about.html">about</a></li>
			</ul>	
			<div id="logo">
				<a href="call.jsp"><img src="images/logo.gif" alt="" /></a>
			</div>	
		</div>
	</div>
	<div id="body">
		<div class="section">
			<div>
				<h1>
				<div style="width:400px;height:200px;margin:0 auto;padding:20px;">
<span style="font-size:15px;font-weight:bold;">[幸运数]</span><br/><br/>
 你的幸运数是<%=num%> 【<%=map2.get(num)%>】：<br/>
 代表：<%=map1.get(num)%><br/>
 <br/><br/>
 <!-- <input type="button" value="分享到新浪微博" onclick="javascript:share();"> -->
</div>
				</h1>	
			</div>
		</div>
	</div>
<script type="text/javascript">
	var share=function(){
		var ss='your lucky number is <%=num%>';
		window.location.href='<%=Constant.BASE_URL%>sina/share.jsp?ss='+ss;
	}
</script>
</body>
</html>